package com.fare.taluo.core.domain.system;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Table;

import com.dayatang.domain.Entity;
import com.dayatang.domain.InstanceFactory;
import com.dayatang.domain.QuerySettings;
import com.dayatang.querychannel.support.Page;
import com.fare.taluo.base.ddd.domain.baseentity.BaseEntity;
import com.fare.taluo.core.domain.queue.message.QueueEmailMessageEntity;

/**
 * report email
 * 发送报表的EMAIL
 * @author gan
*/

@javax.persistence.Entity
@Table(name="FDC_EMAIL")
public class EmailEntity extends BaseEntity{
	private static final long serialVersionUID = 1L;
	
	//用户名
	@Column(name ="USERNAME")
	private String userName;
	
	//用户email地址
	@Column(name ="EMAILADDRESS")
	private String emailAddress;
	
	//状态码：1表示发送状态，0表示常用状态
	@Column(name ="STATU")
	private Integer statu;
	
	
	private static EmailEntityRepository emailEntityRepository;
	
	public static EmailEntityRepository getEmailEntityRepository() {
		if(emailEntityRepository == null){
			emailEntityRepository=InstanceFactory.getInstance(EmailEntityRepository.class);
		}
		return emailEntityRepository;
	}

//	public Long getId() {
//		return id;
//	}
//
//	public void setId(Long id) {
//		this.id = id;
//	}
	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getEmailAddress() {
		return emailAddress;
	}

	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}

	public Integer getStatu() {
		return statu;
	}

	public void setStatu(Integer statu) {
		this.statu = statu;
	}

	@Override
	public boolean isNew() {
		return getId() == null || getId().intValue() == 0;
	}
	
	//查找所有Emai 
	public List<EmailEntity> findAllEmail(int statu){
		return getEmailEntityRepository().findAllEmail(statu);
	}
	
	public Page<QueueEmailMessageEntity> findEntityByPage(QueueEmailMessageEntity query,int pageNo, int pageSize){
		return getEmailEntityRepository().findEntityByPage(query, pageNo, pageSize);
	}

	public List<QueueEmailMessageEntity> findEntityByDate(Date createDate){
		return getEmailEntityRepository().findEntityByDate(createDate);
	}
}
